AdvSelectList.strArray = {};

function AdvSelectList(divId)
{
	this.div = divId;
	this.render = function()
	{
		//alert('test');
		var data = document.getElementById(divId).innerHTML;
		document.getElementById(divId).innerHTML = "<div id=\'selectList\'><input type=\'text\' onkeyup=\'AdvSelectList.stringFinder(this)\' id=\'slTextbox\' \/><div id=\'slItems\'><div id=\'slItemsCtnr\'><\/div><\/div><\/div>";
		document.getElementById('slItemsCtnr').innerHTML = data;
		var spanArray = document.getElementById('slItemsCtnr').getElementsByTagName('div');
		
		var ar;
		for(i in spanArray) //Not copying properties right
		{
			AdvSelectList.strArray[i] = spanArray[i];
		}
	}	
	
	this.dataSource = function(data)
	{
		document.getElementById(divId).innerHTML = data;
	}
}

AdvSelectList.stringFinder = function(el)
{
	//alert(str);
	var str = el.value;
	var matchedStrings = '';
	for(var i = 0; i < AdvSelectList.strArray.length; i++)
	{
		var strValue = AdvSelectList.strArray[i].cloneNode(true).innerHTML; //get each element from array
		//alert(strValue.innerHTML);
		for(var j = 0; j < strValue.length; j++)
		{
			if(!(j + str.length > strValue.length))
			{
				if((strValue.substring(j,j + str.length).toLowerCase() == str.toLowerCase()))
				{
					matchedStrings += '<div>' + strValue + '<\/div>';
					break;
				}
			}
		 }
	}
	document.getElementById('slItemsCtnr').innerHTML = matchedStrings;
}